﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace carsitem.kehu
{
    public partial class customer : Form
    {
        public customer()
        {
            InitializeComponent();
        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void UpBt_Click(object sender, EventArgs e)
        {
            
            string customerName = this.NameBox.Text;
            string customersex="男";
            if (this.ManRbt.Checked==true)
            {
                 customersex = "男";
            }
            if (this.WmanRbt.Checked==true)
            {
                 customersex = "女";
            }
            string number = this.NumberBox.Text;
            string company = this.CompanyBox.Text;
            string Address = this.AddressBox.Text;
            string sql = string.Format("insert customerTable values('{0}','{1}','{2}','{3}','{4}')", customerName, customersex, number ,"","");
            if (company!="")
            {
                sql = string.Format("insert customerTable values('{0}','{1}','{2}','{3}','{4}')", customerName, customersex, number,company,"");
            }
            if (Address!="")
            {
                sql = string.Format("insert customerTable values('{0}','{1}','{2}',{3},{4})", customerName, customersex, number, company,Address);
            }
            DBHelper db = new DBHelper();
            bool result= db.ExcuteSql(sql);
            if (result==true)
            {
                MessageBox.Show("添加成功");
            }
            else
            {
                MessageBox.Show("添加失败");
            }
            
        }

        private void customer_Load(object sender, EventArgs e)
        {
            
        }
        private void ManRbt_CheckedChanged(object sender, EventArgs e)
        {
            
        }

        private void OutBt_Click(object sender, EventArgs e)
        {
            //DialogResult dg = MessageBox.Show("确认退出嘛？","退出警告",MessageBoxButtons.YesNo);
            //if (dg==DialogResult.Yes)
            //{
            //    Environment.Exit(0);
            //}
            carsitem.MainInterface.MainInterfaceForm mainInterfaceForm = new carsitem.MainInterface.MainInterfaceForm();//把form1传给form2
            mainInterfaceForm.Show();
            this.Hide();//把自己隐藏了
        }

        private void SexPl_Paint(object sender, PaintEventArgs e)
        {
             
        }

        private void NumberBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void NameBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void AddressBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void CompanyBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void gubianBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void SexLb_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void NameLb_Click(object sender, EventArgs e)
        {

        }

        private void BianHaolb_Click(object sender, EventArgs e)
        {

        }
    }
}
